using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IsometricEngine;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Fated.Scenario.Events;
namespace Fated.Scenario {
    class CardScreen : Renderable{

        const string TarotCardFolder = "TarotCards\\";
        const float cardHeight = .5f;
        const float cardTop = .1f;
        const float fluffTop = cardTop + cardHeight + .1f;
        const float cardHPad = .07f;

        public CardScreen(Cards cur) : base() {
            Vector2 toCenter;

            for (int i = 0; i < cur.cards.Count; ++i) {
                Renderable cardDisplay = new Renderable();
                cardDisplay.renderType = RenderType.NonIsoBitmap;

                cardDisplay.textureID = RenderMngr.loadAsset<Texture2D>(TarotCardFolder + cur.cards[i]);
                cardDisplay.textureSize = RenderMngr.textureSize(cardDisplay.textureID);

                float ratio = (float)cardDisplay.textureSize.Height / (screenSize.Y * cardHeight);
                cardDisplay.textureSize.Height = (int)(screenSize.Y * cardHeight);
                cardDisplay.textureSize.Width = (int)(cardDisplay.textureSize.Width / ratio);

                float newIndex = i - cur.cards.Count / 2.0f;

                float cardArea = cardDisplay.textureSize.Width + screenSize.X * cardHPad;

                cardDisplay.textureSize.X = (int)(newIndex * cardArea + screenSize.X / 2 + screenSize.X * cardHPad / 2);
                cardDisplay.textureSize.Y = (int)(screenSize.Y * cardTop);
                
                this.children.Add(cardDisplay);
            }

            
            //clipText(cur.phrase, ref temp, screenSize.X * textWidth, screenSize.Y * textHeight, 0);
            this.text = wordWrap(cur.phrase, screenSize.X * textWidth);

            toCenter = RenderMngr.textSize(this.text, this.fontID);
            this.textPos = new Vector2((screenSize.X - toCenter.X) / 2.0f, screenSize.Y * fluffTop);
        }
    }
}
